﻿namespace Liger.Web.UI
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class GridBaseSettingsBuilder 
    {

        private readonly GridBaseSettings settings;
        public GridBaseSettingsBuilder(GridBaseSettings settings)
        {
            this.settings = settings;
        }
        /// <summary>
        /// 设置 数据
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public GridBaseSettingsBuilder Data(bool value)
        {
            this.settings.Data = value;
            return this;
        }
        /// <summary>
        /// 设置 头部
        /// </summary>
        public GridBaseSettingsBuilder Title(string value)
        {
            this.settings.Title = value;
            return this;
        }
        /// <summary>
        /// 设置 宽度值
        /// </summary>
        public GridBaseSettingsBuilder Width(int value)
        {
            this.settings.Width = value.ToString();
            return this;
        }
        /// <summary>
        /// 设置 宽度值
        /// </summary>
        public GridBaseSettingsBuilder Width(string value)
        {
            this.settings.Width = value;
            return this;
        }
         /// <summary>
        /// 设置 高度值
        /// </summary>
        public GridBaseSettingsBuilder Height(int value)
        {
            this.settings.Height = value.ToString();
            return this;
        }
        /// <summary>
        /// 设置 高度值
        /// </summary>
        public GridBaseSettingsBuilder Height(string value)
        {
            this.settings.Height = value;
            return this;
        }
        

        /// <summary>
        /// 设置 table是否可伸缩(不可用)
        /// </summary>
        public GridBaseSettingsBuilder Resizable(bool value)
        {
            this.settings.Resizable = value;
            return this;
        }



        /// <summary>
        /// 设置 是否显示'显示隐藏Grid'按钮 
        /// </summary>
        public GridBaseSettingsBuilder ShowTableToggleBtn(bool value)
        {
            this.settings.ShowTableToggleBtn = value;
            return this;
        }
        /// <summary>
        /// 设置 切换每页记录数是否应用ligerComboBox
        /// </summary>
        public GridBaseSettingsBuilder SwitchPageSizeApplyComboBox(bool value)
        {
            this.settings.SwitchPageSizeApplyComboBox = value;
            return this;
        }
        /// <summary>
        /// 设置 是否滚动
        /// </summary>
        public GridBaseSettingsBuilder IsScroll(bool value)
        {
            this.settings.IsScroll = value;
            return this;
        }
        /// <summary>
        /// 设置 是否以窗口的高度为准 height设置为百分比时可用
        /// </summary>
        public GridBaseSettingsBuilder InWindow(bool value)
        {
            this.settings.InWindow = value;
            return this;
        }
        /// <summary>
        /// 设置 默认时间显示格式
        /// </summary>
        public GridBaseSettingsBuilder DateFormat(string value)
        {
            this.settings.DateFormat = value;
            return this;
        }
        /// <summary>
        /// 设置 高度补差,当设置height:100%时，可能会有高度的误差，可以通过这个属性调整
        /// </summary>
        public GridBaseSettingsBuilder HeightDiff(int value)
        {
            this.settings.HeightDiff = value;
            return this;
        }
        /// <summary>
        /// 设置 Grid 附加 CSS 类名
        /// </summary>
        public GridBaseSettingsBuilder CssClass(string value)
        {
            this.settings.CssClass = value;
            return this;
        }

        /// <summary>
        /// 设置 初始化时是否不加载
        /// </summary>
        public GridBaseSettingsBuilder DelayLoad(bool value)
        {
            this.settings.DelayLoad = value;
            return this;
        }
        /// <summary>
        /// 设置 数据过滤查询函数名,(参数一 data item，参数二 data item index)
        /// </summary>
        public GridBaseSettingsBuilder Where(string functionName)
        {
            this.settings.Where = () => functionName;
            return this;
        }
        /// <summary>
        /// 设置 数据过滤查询函数,(参数一 data item，参数二 data item index)
        /// </summary>
        public GridBaseSettingsBuilder Where(Func<string> function)
        {
            this.settings.Where = function;
            return this;
        }
        /// <summary>
        /// 设置 获取时间 函数名
        /// </summary>
        public GridBaseSettingsBuilder RenderDate(string functionName)
        {
            this.settings.Where = () => functionName;
            return this;
        }

        /// <summary>
        /// 设置 获取时间 函数
        /// </summary>
        public GridBaseSettingsBuilder RenderDate(Func<string> function)
        {
            this.settings.Where = function;
            return this;
        }

    }
}
